package net.dfrz.action.qt;



import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import net.dfrz.domain.PageBean;
import net.dfrz.domain.QueryInfo;
import net.dfrz.service.qtBusinessService;
import net.dfrz.service.impl.qtBusinessServiceImp;
import net.dfrz.util.WebUtils;



public class QtIndexMainPage extends HttpServlet {

		private qtBusinessService service = new qtBusinessServiceImp();
		public void doGet(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {

			QueryInfo info = WebUtils.request3Bean(request, QueryInfo.class);
			String category_id = request.getParameter("category_id");
			if(category_id!=null && !category_id.trim().equals("")){
				info.setQueryname("category_id");
				info.setQueryvalue(category_id);
			}
			
			List categories = service.getAllCategory();
			PageBean pagebean = service.goodsPageQuery(info);
			
			request.setAttribute("categories", categories);
			request.setAttribute("pagebean", pagebean);
			
			request.getRequestDispatcher("/qt/main.jsp").forward(request, response);
			
		}

		public void doPost(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
			doGet(request, response);
		}

	}


